package com.heima.mapper;

import com.github.pagehelper.Page;
import com.heima.pojo.Task;
import com.heima.pojo.TaskDetail;
import com.heima.pojo.TaskType;
import com.heima.pojo.dto.TaskPageDto;
import com.heima.pojo.vo.*;
import lombok.extern.slf4j.Slf4j;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.Date;
import java.util.List;

@Mapper
public interface TaskMapper {

    /**
     * 工单统计
     * @param start
     * @param end
     * @return
     */
    List<TaskReportInfoVo> taskReportInfo(Date start, Date end);

    void insert(Task task);

    /**
     * 根据id查询
     * @param taskId
     * @return
     */
    @Select("select * from tb_task where task_id = #{taskId}")
    Task queryById(Integer taskId);

    @Update("update tb_task set desc = #{desc},update_time = #{updateTime} where task_id = #{taskId}")
    void update(Task task);

    List<TaskCountVo> collectReport(Date start, Date end);

    List<UserWorkCountVo> userWorkTop10(Date start, Date end, Integer flag, String regionId);

    Page<TaskVo> pageQueryRepair(TaskPageDto dto);

    @Select("select * from tb_task_type")
    List<TaskType> queryAllType();

    @Select("select * from tb_task_status_type")
    List<TaskStatusVo> queryAllStatus();

    Task queryTaskInfo(Integer taskId);

    Task getSupplyInfo(Integer taskId);
    @Select("select * from tb_task_details where task_id = #{taskId}")
    List<TaskDetail> getTaskDetails(Integer taskId);

    Integer getRepairTimes(Date start, Date end, String innerCode);
}
